package com.yonyou.pmclouds.procedureinspect.rmiimpl;

import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.processinspect.entity.ProcedureInspectVO;
import com.yonyou.pmclouds.processinspect.rmiitf.ProcedureInspectRemoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ReferenceCheckOfProcedureInspect implements ReferenceCheckOfBusiness{
    @Autowired
    private ProcedureInspectRemoteService query;
    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECT,RefCodeConst.PROCEDURE};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code = null;
        if(RefCodeConst.PROJECT.equals(bdCode)) {
            code = ProcedureInspectVO.PK_PROJECT;
        } else if(RefCodeConst.PROCEDURE.equals(bdCode)) {
            code = ProcedureInspectVO.PK_PROCEDURE;
        } else {
            throw new BusinessException("工序报验暂未引用该档案!");
        }
        return query.queryRefByIds(code, keys);
    }

}
